﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.Data.DbUtils.DataMapping;
using PMS.Data.Entities.Messages;

namespace PMS.Data.EntityMap.Messages
{
    /// <summary>
    /// Represents a QueuedEmail mapping configuration
    /// </summary>
    public partial class QueuedEmailMap : PMSEntityTypeConfiguration<QueuedEmail>
    {
        #region Methods

        /// <summary>
        /// Configures the entity
        /// </summary>
        /// <param name="builder">The builder to be used to configure the entity</param>
        public override void Configure(EntityTypeBuilder<QueuedEmail> builder)
        {
            builder.ToTable("msg_queuedemail");
            builder.HasKey(queued => queued.Id);

            builder.Property(queued => queued.From).HasMaxLength(200).IsRequired();
            builder.Property(queued => queued.FromName).HasMaxLength(200);
            builder.Property(queued => queued.To).HasMaxLength(200).IsRequired();
            builder.Property(queued => queued.ToName).HasMaxLength(200);
            builder.Property(queued => queued.ReplyTo).HasMaxLength(200);
            builder.Property(queued => queued.ReplyToName).HasMaxLength(200);
            builder.Property(queued => queued.CC).HasMaxLength(1024);
            builder.Property(queued => queued.Bcc).HasMaxLength(1024);
            builder.Property(queued => queued.Subject).HasMaxLength(200).IsRequired();
            builder.Property(queued => queued.AttachmentFileName).HasMaxLength(500);
            builder.Property(queued => queued.AttachmentFilePath).HasMaxLength(500);
            builder.Property(queued => queued.SentTries).IsRequired();
            builder.Property(queued => queued.IsActive).IsRequired();
            builder.Property(queued => queued.CreatedOnTimeUtc).IsRequired();
            builder.Property(queued => queued.UpdatedOnTimeUtc).IsRequired();
            base.Configure(builder);
        }

        #endregion
    }
}
